<template lang="jade">
div
  h-loader-full(url='loader',:setdata='false')
  h-data-adder(url='product/add')
    m-title(icon='add',name='添加岗位类型')
    table.single
      mf-row(name='所属一级岗位类别', msg='必选项')
        select#bcat(v-model='data.bid',@change='linkage(data.bid)')
          option(value=0) 作为顶级类别
          option(v-for='v in bigcat',:value='v.id') {{v.name}}
      mf-row(name='所属二级岗位类别', msg='必选项',v-if="data.bid != '0'")
        select#scat(v-model='data.mid')
          option(value=0) 作为顶级类别
          option(v-for='v in category',:value='v.id') {{v.name}}
      mf-row(name='岗位名称', msg='1-40位'): input(type = 'text',v-model='data.name')
      mf-row(name='')
        button(id='button') 确认提交
</template>
<script>
export default {
	data () {
		return {
			loader : {
				bigcat : 'bigcat/list/one',
			},
			category:[],
			bigcat: [],
			smallall: [],
      smallcat: [{id:0, name:'请选择小类别'}],
			data: {
				name: '',
				bid: 0,
				mid: 0,
			},
      
		}
	},
	methods: {
		addAfter (res) {
			this.$msg.success()
			window.location.reload()
		},
		loadAfter (res) {
			this.bigcat = res.bigcat
		},
		/**
		 * 联动
		 */
		linkage (id) {
      this.$ajax.get('smallcat/list/' + id,(res)=>{
        this.category = res.data
      },(res)=>{
        this.$msg.error(res.message)
      })
		},
    
	}
}
</script>